import time

from selenium import webdriver
from selenium.webdriver.common.by import By
dr =webdriver.Firefox()
dr.get('http://stu000337/dbshop/public/')

# 1.输入send_keys()
# time.sleep(2)
# dr.find_element(By.XPATH,'//input').send_keys('慈溪炸弹投出')
#
# # 2.清空 clear()
# time.sleep(2)
# dr.find_element(By.XPATH,'//input').clear()

# 3.点击 click()
time.sleep(2)
dr.find_element(By.ID,'J_miniCart').click()

# # 4.获取文本 text
# t=dr.find_element(By.XPATH,'//h3').text
# print(t)

# 5.获取属性值 get_attribute(属性)
# t=dr.find_element(By.XPATH,'//input[@type="button"]').get_attribute('value')
# print(t)

# 6.获取坐标 location
# t=dr.find_element(By.XPATH,'//input[@type="button"]').location
# print(t)

# 7.判断元素存在 is_displayed()
try:
    dr.find_element(By.XPATH,'//input[@class="search-text"]').is_displayed()
except Exception as e:
    print('元素不存在')
    print(e)
else:
    print('元素存在')